//@ts-ignore
import knightPng from "res://assets/knight.png";
import BaseSprite from "./base_sprite";

export default class KnightSprite extends BaseSprite {
    frameIndex = 10;
    frameStart = 10;
    frameEnd = 19;

    constructor(){
        // 构造函数必须先调用super()
        super();
        this.texture = knightPng;
        this.position = new godot.Vector2(300,300)
        
        this.set_hframes(10);
        this.set_vframes(2);

        this.set_frame(this.frameIndex);
    }

    _process(delta: number): void {
        // 动画效果
        if(this.frameIndex < 20){
            this.frameIndex = this.frameIndex + 0.3
        }else{
            this.frameIndex = this.frameStart
        }
        this.set_frame(Math.floor(this.frameIndex));
        
        // 父类基础
        super._process(delta);

    }

}